package com.sun.config;

import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.spring.annotation.ApolloConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * API方式读取YML或YAML
 */
@Configuration
public class YmlConfig {

    @ApolloConfig("test-yml.yml")
    private Config ymlConfig;

    @ApolloConfig("test-yaml.yaml")
    private Config yamlConfig;

    @Bean
    public void configYml() {
        String apolloParam = ymlConfig.getProperty("test.param3", "DefaultValue");
        System.out.println("YmlConfig test.param3 = " + apolloParam);
    }

    @Bean
    public void configYaml() {
        String apolloParam = yamlConfig.getProperty("test.param4", "DefaultValue");
        System.out.println("YmlConfig test.param4 = " + apolloParam);
    }

}
